using System.Collections.Generic;
using Framework.Library.Core.Config;
using Framework.Library.Data.DAO.SqlServer;
using Framework.Library.Data.IDAO;
using System.Collections;
using Framework.Library.Core.Provider.Caches;

namespace Framework.Library.Data.DAO
{
    public class ManagerFactory
    {
        private static readonly Hashtable dicts;

        static ManagerFactory()
        {
            var cfg = new Configurations();
            //dicts = (Hashtable)Caching.GetHashCache("NightStalker", "cache=factory");
            dicts = Caching.Data.Get<Hashtable>("NightStalker");
            if (dicts == null)
            {
                dicts = new Hashtable();
                lock (dicts)
                {
                    switch (Configurations.DATAPROVIDER)
                    {
                        case "SqlServer":

                            #region DBCommon

                            dicts.Add("DAOEntity", new DAOEntity());

                            #endregion

                            #region Portal

                            dicts.Add("PortalPortalManager", new PortalPortalManager());
                            dicts.Add("PortalRoleManager", new PortalRoleManager());
                            dicts.Add("PortalUserManager", new PortalUserManager());
                            dicts.Add("PortalMenuManager", new PortalMenuManager());
                            dicts.Add("PortalSettingManager", new PortalSettingManager());
                            dicts.Add("PortalLanguageComManager", new PortalLanguageComManager());
                            #endregion

                            #region Teenio
                            dicts.Add("TeenioCategoryManager", new TeenioCategoryManager());
                            dicts.Add("TeenioContentManager", new TeenioContentManager());
                            dicts.Add("TeenioPermissionManager", new TeenioPermissionManager());
                            dicts.Add("TeenioPaymentManager", new TeenioPaymentManager());
                            #endregion

                            dicts.Add("AdsManager", new AdsManager());
                            break;
                        case "MySql":
                            break;
                        case "Oracle":

                            #region DBCommon

                            dicts.Add("DAOEntity", new Oracle.DAOEntity());

                            #endregion

                            #region Portal

                            dicts.Add("PortalPortalManager", new Oracle.PortalPortalManager());
                            dicts.Add("PortalRoleManager", new Oracle.PortalRoleManager());
                            dicts.Add("PortalUserManager", new Oracle.PortalUserManager());
                            dicts.Add("PortalMenuManager", new Oracle.PortalMenuManager());
                            dicts.Add("PortalSettingManager", new Oracle.PortalSettingManager());
                            dicts.Add("PortalLanguageComManager", new Oracle.PortalLanguageComManager());
                            
                            #endregion                           

                            #region Teenio
                            dicts.Add("TeenioCategoryManager", new Oracle.TeenioCategoryManager());
                            dicts.Add("TeenioContentManager", new Oracle.TeenioContentManager());
                            dicts.Add("TeenioPermissionManager", new Oracle.TeenioPermissionManager());
                            dicts.Add("TeenioPaymentManager", new TeenioPaymentManager());
                            #endregion

                            dicts.Add("AdsManager", new Oracle.AdsManager());
                            break;
                        case "SQLite":
                            break;
                        default:
                            break;
                    }
                    //Caching.SetHashCache("NightStalker", "cache=factory", dicts);
                    Caching.Data.Set("NightStalker", dicts);
                }
            }
        }

        #region DBCommon

        public static IDAOEntity DAOEntity
        {
            get { return (IDAOEntity) dicts["DAOEntity"]; }
        }

        #endregion
        
        #region Portal

        public static IPortalLanguageManager PortalLanguageManager
        {
            get { return (IPortalLanguageManager) dicts["PortalLanguageManager"]; }
        }

        public static IPortalPortalManager PortalPortalManager
        {
            get { return (IPortalPortalManager) dicts["PortalPortalManager"]; }
        }

        public static IPortalRoleManager PortalRoleManager
        {
            get { return (IPortalRoleManager) dicts["PortalRoleManager"]; }
        }

        public static IPortalUserManager PortalUserManager
        {
            get { return (IPortalUserManager) dicts["PortalUserManager"]; }
        }

        public static IPortalMenuManager PortalMenuManager
        {
            get { return (IPortalMenuManager) dicts["PortalMenuManager"]; }
        }

        public static IPortalStatisticManager PortalStatisticManager
        {
            get { return (IPortalStatisticManager) dicts["PortalStatisticManager"]; }
        }

        public static IPortalSettingManager PortalSettingManager
        {
            get { return (IPortalSettingManager)dicts["PortalSettingManager"]; }
        }

        public static IPortalLanguageComManager PortalLanguageComManager
        {
            get { return (IPortalLanguageComManager)dicts["PortalLanguageComManager"]; }
        }
        
        #endregion
        
        #region Teenio


        public static ITeenioCategoryManager TeenioCategoryManager
        {
            get { return (ITeenioCategoryManager)dicts["TeenioCategoryManager"]; }
        }
        public static ITeenioContentManager TeenioContentManager
        {
            get { return (ITeenioContentManager)dicts["TeenioContentManager"]; }
        }
        public static ITeenioPermissionManager TeenioPermissionManager
        {
            get { return (ITeenioPermissionManager)dicts["TeenioPermissionManager"]; }
        }
        public static ITeenioPaymentManager TeenioPaymentManager
        {
            get { return (ITeenioPaymentManager)dicts["TeenioPaymentManager"]; }
        }
        #endregion

        public static IAdsManager AdsManager
        {
            get { return (IAdsManager)dicts["AdsManager"]; }
        }
    }
}